﻿using AutoMapper;
using System;
using System.Linq;
using DomainModels = Ideaa.Domain.Models;
using PersistedModels = Ideaa.Data.Models;
using Ideaa.Core.Extensions;

namespace Ideaa.Data.Mappings
{
    public class PersistedToDomainMappingProfile : Profile
    {
        public override string ProfileName
        {
            get { return "PersistedToDomainMappings"; }
        }

        protected override void Configure()
        {
            Mapper.CreateMap<PersistedModels.Base.BaseEntity, DomainModels.Base.BaseEntity>()
                .Include<PersistedModels.Base.PostEntity, DomainModels.Base.PostEntity>()
                .ForMember(dest => dest.CreatedUserId, opt => opt.MapFrom( src => src.UserId));

            Mapper.CreateMap<PersistedModels.Base.PostEntity, DomainModels.Base.PostEntity>()
                .Include<PersistedModels.Idea, DomainModels.Idea.Idea>()
                .Include<PersistedModels.Suggestion, DomainModels.Idea.Suggestion>();

            Mapper.CreateMap<PersistedModels.Idea, DomainModels.Idea.Idea>();

            Mapper.CreateMap<PersistedModels.Suggestion, DomainModels.Idea.Suggestion>();
        }
    }
}
